﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Workflow.Model;


namespace Workflow.Service.Menu.Models
{
    public class MenuHelper
    {
        #region GPEEM
        private MenuModels GPEEMInquiry
        {
            get
            {
                var menu = new GPEEM.Inquiry();
                return menu.GetMenu();
            }
        }
        private MenuModels GPEEMMyTask
        {
            get
            {
                var menu = new GPEEM.MyTask();
                return menu.GetMenu();
            }
        }
        private MenuModels GPEEMCaseMonitor
        {
            get
            {
                var menu = new GPEEM.CaseMonitor();
                return menu.GetMenu();
            }
        }
        private MenuModels GPEEMPAMonitor
        {
            get
            {
                var menu = new GPEEM.PAMonitor();
                return menu.GetMenu();
            }
        }
        #endregion
        #region MSDEEM
        private MenuModels MSDEEMInquiry
        {
            get
            {
                var menu = new MSDEEM.Inquiry();
                return menu.GetMenu();
            }
        }
        private MenuModels MSDEEMCaseMonitor
        {
            get
            {
                var menu = new MSDEEM.CaseMonitor();
                return menu.GetMenu();
            }
        }
        #endregion
        #region Report
     
        private MenuModels ReportEEM
        {
            get
            {
                var menu = new Report.EEMReport();
                return menu.GetMenu();
            }
        }
		
        #endregion
        #region Maintain
        private MenuModels MaintainUser
        {
            get
            {
                var menu = new Maintain.User();
                return menu.GetMenu();
            }
        }
        private MenuModels MaintainSupplier
        {
            get
            {
                var menu = new Maintain.Supplier();
                return menu.GetMenu();
            }
        }
		private MenuModels MaintainHoliday
		{
			get
			{
				var menu = new Maintain.Holiday();
				return menu.GetMenu();
			}
		}
        #endregion


    	/// <summary>
    	/// 创建菜单方法，每个参数代表一个节点，true为该角色有权限浏览该节点，false相反。
    	/// </summary>
    	/// <param name="gpptpinquiry"></param>
    	/// <param name="gpptpmytask"></param>
    	/// <param name="gpptpcasemonitor"></param>
    	/// <param name="gpptppamonitor"></param>
    	/// <param name="gpeeminquiry"></param>
    	/// <param name="gpeemmytask"></param>
    	/// <param name="gpeemcasemonitor"></param>
    	/// <param name="gpeempamonitor"></param>
    	/// <param name="msdptpinquiry"></param>
    	/// <param name="msdptpcasemonitor"></param>
    	/// <param name="msdeeminquiry"></param>
    	/// <param name="msdeemcasemonitor"></param>
    	/// <param name="reportptp"></param>
    	/// <param name="reporteem"></param>
    	/// <param name="maintainuser"></param>
    	/// <param name="maintainsupplier"></param>
    	/// <param name="maintainholiday"></param>
    	/// <returns>JsonMenus</returns>
    	public JsonMenus BuilderMenu(String rolename,
											bool gpeeminquiry,bool gpeemmytask, bool gpeemcasemonitor, bool gpeempamonitor,
											bool msdeeminquiry, bool msdeemcasemonitor,
											bool reporteem,
											bool maintainuser,bool maintainsupplier, bool maintainholiday
											
			)
        {
          
            var gpeemmMenus = new List<MenuModels>();
            if (gpeeminquiry) gpeemmMenus.Add(this.GPEEMInquiry);
            if (gpeemmytask) gpeemmMenus.Add(this.GPEEMMyTask);
            if (gpeemcasemonitor) gpeemmMenus.Add(this.GPEEMCaseMonitor);
            if (gpeempamonitor) gpeemmMenus.Add(this.GPEEMPAMonitor);
			
            var msdeemMenus = new List<MenuModels>();
            if (msdeeminquiry) msdeemMenus.Add(this.MSDEEMInquiry);
            if (msdeemcasemonitor) msdeemMenus.Add(this.MSDEEMCaseMonitor);
			
            var reportMenus = new List<MenuModels>();
           if (reporteem) reportMenus.Add(this.ReportEEM);
          
            var maintainMenus = new List<MenuModels>();
            if (maintainuser) maintainMenus.Add(this.MaintainUser);
            if (maintainsupplier) maintainMenus.Add(this.MaintainSupplier);
			if (maintainholiday) maintainMenus.Add(this.MaintainHoliday);

            var gpeemmenu = new MenuModels("18", "GP-EEM", "#", "icon-sys", gpeemmMenus);
            var msdeemmenu = new MenuModels("22", "MSD-EEM", "#", "icon-sys", msdeemMenus);
            var reportmenu = new MenuModels("4", "Report", "#", "icon-sys", reportMenus);
            var maintainmenu = new MenuModels("10", "Maintain", "#", "icon-sys", maintainMenus);
			
            var treeMenu = new List<MenuModels>();
            if (gpeemmMenus.Count > 0) treeMenu.Add(gpeemmenu);
			if (msdeemMenus.Count > 0) treeMenu.Add(msdeemmenu);
            if (reportMenus.Count > 0) treeMenu.Add(reportmenu);
            if (maintainMenus.Count> 0) treeMenu.Add(maintainmenu);

            var jsonMenus = new JsonMenus(treeMenu);
            return jsonMenus;
        }
    }
}
